package com.db.springcloud.config;

import com.db.loadbalanceconfig.CustomLoadBalanceConfig;
import com.db.loadbalanceconfig.RandomLoadBalancerConfig;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
//@LoadBalancerClient(value = "SPRINGCLOUD-PROVIDER-USER", configuration = RandomLoadBalancerConfig.class)
@LoadBalancerClient(value = "SPRINGCLOUD-PROVIDER-USER", configuration = CustomLoadBalanceConfig.class)
public class RestTemplateConfig {

    //配置负载均衡实现template

    @Bean
    @LoadBalanced  //Ribbon
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }


}
